package me.gm.stcont.controller;

import java.util.Locale;

import org.apache.log4j.Level;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class MainController extends BaseController {

	public MainController() {
	}

	@RequestMapping(value = "/home", method = RequestMethod.GET)
	public String home() {
		getLogger().debug("started home");
		getLogger().debug("finished home");

		return "home";
	}

	@RequestMapping(value = "/main", method = RequestMethod.GET)
	public String main(Model model, Locale locale) {
		getLogger().info("started main");

		if (getLogger().isEnabledFor(Level.DEBUG)) {
			getLogger().debug("model: " + model);
			getLogger().debug("locale: " + locale);
		}

		model.addAttribute("locale", locale);

		getLogger().info("finished main");

		return "main";
	}

	@RequestMapping(value = "/content/{content}", method = RequestMethod.GET)
	public String content(@PathVariable("content") String content) {
		getLogger().info("started content");

		if (getLogger().isEnabledFor(Level.DEBUG)) {
			getLogger().debug("content: " + content);
		}

		getLogger().info("finished content");

		return "content/" + content;
	}

}
